/*
* floyd O(n^3) 求最小环
* 有向无权图
* 矛盾:
*      d[i][i] = 1 
*      d[i][j] == 1 && d[j][i] = 1
* 
*/
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
// #define ONLINE_GUDGE
using LL = long long;
using namespace std;
const int N = 110, M = 10010, INF = 0x3f3f3f3f;

int n, m;
int w[N][N], dist[N][N], pos[N][N]; // w存直连路径长 dist路径长 pos中间点 
int path[N], cnt, ans = INF; // path当前最小环方案 cnt环中点的数量

// void AddEdge(int a, int b, int c)
// { e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx++; }

void GetPath(int i, int j) // 递归处理中间路径
{
    if(!pos[i][j]) return; // i到j的最短路没有经过其他节点
    int k = pos[i][j]; // i -> k -> j
    GetPath(i, k);
    path[cnt++] = k;
    GetPath(k, j);
}

int main()
{
    #ifdef ONLINE_JUDGE

    #else
        freopen("./in.txt", "r", stdin);
    #endif

    ios::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m;
    
    memset(w, INF, sizeof w);

    for(int i = 1; i <= n; i++) w[i][i] = 0;
    
    while(m--){
        int a, b, c; cin >> a >> b >> c;
        w[a][b] = w[b][a] = min(w[a][b], c); // 找到无向图中[a][b]的最短直连路径长
    }

    memcpy(dist, w, sizeof dist); // w -> dist

    for(int k = 1; k <= n; k++){ // 枚举k是i~j的环中点的最大编号
        for(int i = 1; i < k; i++)
            for(int j = i+1; j < k; j++)
                if((LL)w[i][k]+w[k][j]+dist[i][j] < ans){ // 上一轮中的dist[i][j] : i ~ j 中间经过不超过k - 1的最短距离(k是不在路径上的)
                    ans = w[i][k]+w[k][j]+dist[i][j];
                    cnt = 0;
                    path[cnt++] = k;
                    path[cnt++] = i;
                    GetPath(i, j);
                    path[cnt++] = j;
                }
    
        for (int i = 1; i <= n; i ++) 
            for (int j = 1; j <= n; j ++)   
                if (dist[i][j] > dist[i][k] + dist[k][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];  
                    pos[i][j] = k;
                }
    }
    
    if (ans == INF) puts("No solution.");
    else {
        for (int i = 0; i < cnt; i ++) cout << path[i] << ' ';
        cout << endl;
    }
        /* 输出g[][]
        printf("  ");
        for(int i = 0; i < n; i++) printf("%c ", 'A' + i);
        printf("\n");
        for(int i = 0; i < n; i++)
        {
            printf("%c ", 'A' + i);
            for(int j = 0; j < n; j++) if(d[i][j]) printf("1 "); else printf("  ");// printf("%d ", d[i][j]);
            printf("\n");
        }
        */

    
    return 0;
}